import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from keras.models import load_model
from keras.utils.np_utils import to_categorical
from sklearn.preprocessing import LabelEncoder, MinMaxScaler
from sklearn.model_selection import train_test_split
from sklearn.metrics import classification_report

plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False

dateset = pd.read_csv('./data.csv')

le = LabelEncoder()
dateset['target'] = le.fit_transform(dateset['diagnosis'])
dateset.drop("Unnamed: 32", axis=1, inplace=True)
dateset.drop("id", axis=1, inplace=True)
dateset.drop("diagnosis", axis=1, inplace=True)
print(dateset)

Y = dateset['target']
X = dateset.iloc[:, :-1]

# 划分数据集
x_train, x_test, y_train, y_test = train_test_split(X, Y, test_size=0.2, random_state=42)

# 将数据集标签转化为one-hot向量格式
y_test_one = to_categorical(y_test, 2)

# 进行归一化操作
sc = MinMaxScaler(feature_range=(0, 1))
x_test = sc.fit_transform(x_test)

model = load_model('model.h5')

predict = model.predict(x_test)

y_predict = np.argmax(predict, axis=1)

report = classification_report(y_test, y_predict)
print(report)
